import * as constants from './constants';
import { fromJS } from 'immutable';

const defaultState=fromJS({
    loading:true,
    formData:{
        arr:['title','keywords','description','template']
        ,title:{type:'input',title:'站点名称',name:'title',autoFocus:true,placeholder:"请输入站点名称",rules:[{
            required: true,
            whitespace: true,
            message: '站点名称不能为空'
        }]}
        ,keywords:{type:'input',title:'关键字',name:'keywords'}
        ,description:{type:'text',title:'站点描述Seo',rows:4,name:'description'}
        ,template:{type:'input',title:'使用模板',name:'template',rules:[{
            required: true,
            whitespace: true,
            message: '模板不能为空'
        }]}
    },
    data:{}
});
export default (state=defaultState,action)=>{
    switch (action.type) {
        case constants.DATA:
            return state.merge({
                data : fromJS(action.data),
            })
        case constants.LOADING:
            return state.merge({
                loading : action.loading
            })
        default:
            break;
    }
    return state;
}